package com.easylinkin.sm.util;

import java.util.Map;
import java.util.Objects;
import lombok.experimental.UtilityClass;
import org.springframework.context.i18n.LocaleContextHolder;
import site.morn.core.CriteriaMap;

/**
 * @author wujie
 * @since 0.1.1,  2019/08/26
 */
@UtilityClass
public class TranslateUtils {

  public static Map<String, Object> putLanguage(Map<String, Object> params) {
    return putLanguage(params, "language");
  }

  public static Map<String, Object> putLanguage(Map<String, Object> params, String languageKey) {
    if (Objects.isNull(params)) {
      params = new CriteriaMap();
    }

    (params).put(languageKey, getLanguage());
    return params;
  }

  public static String getLanguage() {
    return LocaleContextHolder.getLocale().toString().toUpperCase();
  }

}
